# 王磊的作业
names = [
    ["曹操","56","男","106","IBM", 500 ,"50"],
    ["大乔","19","女","230","微软", 501 ,"60"],
    ["小乔", "19", "女", "210", "Oracle", 600, "60"],
    ["许褚", "45", "男", "230", "Tencent", 700 , "10"]
]
#统计每个人的平均薪资：
sum=0
for i in names:
    for j in i:
        if j == i[5]:
            sum+=j
avg=sum/len(names)
print('平均薪资：',avg)

#统计每个人的平均年龄
age=0
for i in names:
    for j in i:
        if j == i[1]:
            j=int(j)
            age+=j
avg=age/len(names)
print('平均年龄：',avg)

#新来员工
names.append(['刘备','45','男','220','alibaba',500,'30'])

#男女人数
x=[]
for i in names:
    for j in i:
        if j==i[2]:
            x.append(j)
y={}
for i in x:
    y[i] = x.count(i)
for n, m in y.items():
        print(n, '有', m, '人')

#每个部门的人数
for i in names:
    for j in i:
        if j==i[6]:
            x.append(j)
y={}
for i in x:
    y[i] = x.count(i)
for n, m in y.items():
        print(n, '部门有', m, '人')